<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
 *
 * @package		helpers
 * @author		Glen.luo
 * @since		Version 1.0
 */

// ------------------------------------------------------------------------

/**
 * 根据当前用户的权限生成相关的侧边栏操作菜单.
 *
 * @access	public
 * @return	array
 */
if ( ! function_exists('menu'))
{
	function menu()
    {
        $CI = & get_instance();
        $CI->load->helper('url');
        $CI->load->config('menu');
        $modules = $CI->config->item('modules');
        foreach ($modules as $i => $module) {
            foreach ($module['children'] as $j => $item) {
                if ( !in_array($item['priv'], $CI->priv) ) {
                    unset($module['children'][$j]);
                }
                else {
                    $module['children'][$j]['url'] = site_url($module['children'][$j]['url']);
                }
            }

            if (empty($module['children'])) {
                unset($modules[$i]);
            }
        }

        return $modules;
	}
}

/**
 * 根据当前用户的权限生成相关的侧边栏操作菜单.
 *
 * @access	public
 * @param	array	the nav path config.
 * @return	array
 */
if ( ! function_exists('breadcrumb'))
{
	function breadcrumb($config = array())
    {
        $CI = & get_instance();
        $CI->load->helper('url');

        if (empty($config)) {
            $config = array(
                '首页'                  =>  site_url('/'),
                $CI::controller_title   =>  site_url('/' . $CI->uri->rsegment(1) . '/index'),
                $CI->action_title       =>  site_url('/' . $CI->uri->rsegment(1) . '/' . $CI->uri->rsegment(1)),
            );
        }

        return $config;
	}
}

/* End of file Admin_breadcrumb_helper.php */
/* Location: ./application/helpers/Admin_breadcrumb_helper.php */
